package com.cj.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@Controller
public class ExceptionController {


    @RequestMapping("/doHandleRequest/{i}/{j}")
    @ResponseBody
    public String doHandleRequest(@PathVariable Integer i,@PathVariable Integer j){
//        Integer value = (int)Math.random() *500;
            return "结果是---->" + i / j;
    }

    @ExceptionHandler(Exception.class)
    //只能在本类中使用
    @ResponseBody
    public String doHandleException(Exception e){
        return e.toString();
    }
}
